package com.task.manager.mapper;

import com.task.manager.domain.Project;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface ProjectMapper {
	@Delete({ "delete from t_project", "where ID = #{id,jdbcType=INTEGER}" })
	int deleteByPrimaryKey(Integer id);

	@Insert({ "insert into t_project (ID, PROJECT_NAME, ", "PROJECT_CODE, CREATE_TIME, ", "UPDATE_TIME)", "values (#{id,jdbcType=INTEGER}, #{projectName,jdbcType=VARCHAR}, ",
			"#{projectCode,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, ", "#{updateTime,jdbcType=VARCHAR})" })
	int insert(Project record);

	@InsertProvider(type = ProjectSqlProvider.class, method = "insertSelective")
	int insertSelective(Project record);

	@Select({ "select", "ID, PROJECT_NAME, PROJECT_CODE, CREATE_TIME, UPDATE_TIME", "from t_project", "where ID = #{id,jdbcType=INTEGER}" })
	@Results({ @Result(column = "ID", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "PROJECT_NAME", property = "projectName", jdbcType = JdbcType.VARCHAR),
			@Result(column = "PROJECT_CODE", property = "projectCode", jdbcType = JdbcType.VARCHAR), @Result(column = "CREATE_TIME", property = "createTime", jdbcType = JdbcType.VARCHAR),
			@Result(column = "UPDATE_TIME", property = "updateTime", jdbcType = JdbcType.VARCHAR) })
	Project selectByPrimaryKey(Integer id);

	@UpdateProvider(type = ProjectSqlProvider.class, method = "updateByPrimaryKeySelective")
	int updateByPrimaryKeySelective(Project record);

	@Update({ "update t_project", "set PROJECT_NAME = #{projectName,jdbcType=VARCHAR},", "PROJECT_CODE = #{projectCode,jdbcType=VARCHAR},", "CREATE_TIME = #{createTime,jdbcType=VARCHAR},",
			"UPDATE_TIME = #{updateTime,jdbcType=VARCHAR}", "where ID = #{id,jdbcType=INTEGER}" })
	int updateByPrimaryKey(Project record);
}